home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performMakeBrushSpring.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  8.0 KB  |  370 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  March 1999
  22. //  Author:         dbrins 
  23. //
  24. //  Description:
  25. //
  26. //  Option box for the makeBrushSpring command 
  27. //
  28.  
  29. //
  30. //  Procedure Name:
  31. //      setOptionVars
  32. //
  33. //  Description:
  34. //        Initialize the option values.
  35. //
  36. //  Input Arguments:
  37. //        Whether to set the options to default values.
  38. //
  39. //  Return Value:
  40. //      None.
  41. //
  42. proc setOptionVars(int $forceFactorySettings)
  43. {
  44.     //    StartFrame.
  45.     //
  46.     if ($forceFactorySettings || !`optionVar -exists makeBrushSpringStartFrame`) {
  47.         optionVar -intValue makeBrushSpringStartFrame 1;
  48.     }
  49.  
  50.     //    Stiffness.
  51.     //
  52.     if ($forceFactorySettings || !`optionVar -exists makeBrushSpringStiffness`) {
  53.         optionVar -floatValue makeBrushSpringStiffness 0.3;
  54.     }
  55.  
  56.     //    Damp.
  57.     //
  58.     if ($forceFactorySettings || !`optionVar -exists makeBrushSpringDamp`) {
  59.         optionVar -floatValue makeBrushSpringDamp .1;
  60.     }
  61.  
  62.     //    Travel.
  63.     //
  64.     if ($forceFactorySettings || !`optionVar -exists makeBrushSpringTravel`) {
  65.         optionVar -floatValue makeBrushSpringTravel 1;
  66.     }
  67. }
  68.  
  69. //
  70. //  Procedure Name:
  71. //      makeBrushSpringSetup
  72. //
  73. //  Description:
  74. //        Update the state of the option box UI to reflect the option values.
  75. //
  76. //  Input Arguments:
  77. //      parent               - Top level parent layout of the option box UI.
  78. //                             Required so that UI object names can be 
  79. //                             successfully resolved.
  80. //
  81. //    forceFactorySettings - Whether the option values should be set to
  82. //                             default values.
  83. //
  84. //  Return Value:
  85. //      None.
  86. //
  87. global proc makeBrushSpringSetup(string $parent, int $forceFactorySettings)
  88. {
  89.     //    Retrieve the option settings
  90.     //
  91.     setOptionVars($forceFactorySettings);
  92.  
  93.     setParent $parent;
  94.  
  95.     //    Query the optionVar's and set the values into the controls.
  96.  
  97.     //    StartFrame.
  98.     //
  99.     intSliderGrp -edit 
  100.         -v `optionVar -query makeBrushSpringStartFrame`
  101.         makeBrushSpringStartFrame;
  102.  
  103.     //    Stiffness.
  104.     //
  105.     floatSliderGrp -edit 
  106.         -v `optionVar -query makeBrushSpringStiffness`
  107.         makeBrushSpringStiffness;
  108.  
  109.     //    Damp.
  110.     //
  111.     floatSliderGrp -edit 
  112.         -v `optionVar -query makeBrushSpringDamp`
  113.         makeBrushSpringDamp;
  114.  
  115.     //    Travel.
  116.     //
  117.     floatSliderGrp -edit 
  118.         -v `optionVar -query makeBrushSpringTravel`
  119.         makeBrushSpringTravel;
  120.  
  121. }
  122.  
  123. //
  124. //  Procedure Name:
  125. //      makeBrushSpringCallback
  126. //
  127. //  Description:
  128. //        Update the option values with the current state of the option box UI.
  129. //
  130. //  Input Arguments:
  131. //      parent - Top level parent layout of the option box UI.  Required so
  132. //               that UI object names can be successfully resolved.
  133. //
  134. //    doIt   - Whether the command should execute.
  135. //
  136. //  Return Value:
  137. //      None.
  138. //
  139. global proc makeBrushSpringCallback(string $parent, int $doIt)
  140. {
  141.     setParent $parent;
  142.  
  143.     //    Set the optionVar's from the control values, and then
  144.     //    perform the command.
  145.  
  146.     //    StartFrame.
  147.     //
  148.     optionVar -intValue makeBrushSpringStartFrame
  149.         `intSliderGrp -query -v makeBrushSpringStartFrame`;
  150.  
  151.     //    Stiffness.
  152.     //
  153.     optionVar -floatValue makeBrushSpringStiffness
  154.         `floatSliderGrp -query -v makeBrushSpringStiffness`;
  155.  
  156.     //    Damp.
  157.     //
  158.     optionVar -floatValue makeBrushSpringDamp
  159.         `floatSliderGrp -query -v makeBrushSpringDamp`;
  160.  
  161.     //    Travel.
  162.     //
  163.     optionVar -floatValue makeBrushSpringTravel
  164.         `floatSliderGrp -query -v makeBrushSpringTravel`;
  165.  
  166.     if ($doIt) {
  167.         performMakeBrushSpring 0;
  168.     }
  169. }
  170.  
  171. //
  172. //  Procedure Name:
  173. //      makeBrushSpringOptions
  174. //
  175. //  Description:
  176. //        Construct the option box UI.  Involves accessing the standard option
  177. //        box and customizing the UI accordingly.
  178. //
  179. //  Input Arguments:
  180. //      None.
  181. //
  182. //  Return Value:
  183. //      None.
  184. //
  185. proc makeBrushSpringOptions()
  186. {
  187.     //    Name of the command for this option box.
  188.     //
  189.     string $commandName = "makeBrushSpring";
  190.  
  191.     //    Build the option box actions.
  192.     //
  193.     string $callback = ($commandName + "Callback");
  194.     string $setup = ($commandName + "Setup");
  195.  
  196.     string $layout = getOptionBox();
  197.     setParent $layout;
  198.     
  199.     setOptionBoxCommandName($commandName);
  200.     
  201.     setUITemplate -pushTemplate DefaultTemplate;
  202.  
  203.     waitCursor -state 1;
  204.  
  205.     tabLayout -tabsVisible 0 -scrollable 1;
  206.     
  207.     string $parent = `columnLayout -adjustableColumn 1`;
  208.     
  209.     floatSliderGrp
  210.         -label "Spring Stiffness"
  211.         -field 1
  212.         -min 0 
  213.         -max 1
  214.         -fieldMaxValue 10
  215.         -pre 4
  216.         makeBrushSpringStiffness;
  217.  
  218.     floatSliderGrp
  219.         -label "Spring Damp"
  220.         -field 1
  221.         -min 0 
  222.         -max 1
  223.         -fieldMaxValue 10
  224.         -pre 4
  225.         makeBrushSpringDamp;
  226.  
  227.     floatSliderGrp
  228.         -label "Spring Travel"
  229.         -field 1
  230.         -min 0 
  231.         -max 100
  232.         -pre 3
  233.         makeBrushSpringTravel;
  234.  
  235.     intSliderGrp
  236.         -label "Start Frame"
  237.         -field 1
  238.         -min 0 
  239.         -max 1000
  240.         -fieldMinValue -10000
  241.         -fieldMaxValue 10000
  242.         makeBrushSpringStartFrame;
  243.  
  244.     waitCursor -state 0;
  245.     
  246.     setUITemplate -popTemplate;
  247.  
  248.     //    'Create' button.
  249.     //
  250.     string $applyBtn = getOptionBoxApplyBtn();
  251.     button -edit
  252.         -label "Create"
  253.         -command ($callback + " " + $parent + " " + 1)
  254.         $applyBtn;
  255.  
  256.     //    'Save' button.
  257.     //
  258.     string $saveBtn = getOptionBoxSaveBtn();
  259.     button -edit 
  260.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  261.         $saveBtn;
  262.  
  263.     //    'Reset' button.
  264.     //
  265.     string $resetBtn = getOptionBoxResetBtn();
  266.     button -edit 
  267.         -command ($setup + " " + $parent + " " + 1)
  268.         $resetBtn;
  269.  
  270.     setOptionBoxTitle("Make Brush Spring Options");
  271.  
  272.     //    Customize the 'Help' menu item text.
  273.     //
  274.     setOptionBoxHelpTag( "MakeBrushSpring" );
  275.  
  276.     eval (($setup + " " + $parent + " " + 0));    
  277.  
  278.     showOptionBox();
  279. }
  280.  
  281. //
  282. //  Procedure Name:
  283. //      makeBrushSpringHelp
  284. //
  285. //  Description:
  286. //        Return a short description about this command.
  287. //
  288. //  Input Arguments:
  289. //      None.
  290. //
  291. //  Return Value:
  292. //      string.
  293. //
  294. proc string makeBrushSpringHelp()
  295. {
  296.     return 
  297.     "  Command: makeBrushSpring - create spring expressions on Paint Effects strokes.\n" +
  298.     "Selection: strokes and brushes";
  299. }
  300.  
  301. //
  302. //  Procedure Name:
  303. //      assembleCmd
  304. //
  305. //  Description:
  306. //        Construct the command that will apply the option box values.
  307. //
  308. //  Input Arguments:
  309. //      None.
  310. //
  311. proc string assembleCmd()
  312. {
  313.     string $cmd = "makeBrushSpring";
  314.  
  315.     setOptionVars(false);
  316.  
  317.     $cmd = ($cmd
  318.         + " " + `optionVar -query makeBrushSpringStiffness` 
  319.         + " " + `optionVar -query makeBrushSpringDamp` 
  320.         + " " + `optionVar -query makeBrushSpringTravel` 
  321.         + " " + `optionVar -query makeBrushSpringStartFrame` 
  322.         );
  323.  
  324.     return $cmd;
  325. }
  326.  
  327. //
  328. //  Procedure Name:
  329. //      performMakeBrushSpring
  330. //
  331. //  Description:
  332. //        Perform the makeBrushSpring command using the corresponding 
  333. //        option values.
  334. //
  335. //  Input Arguments:
  336. //      0 - Execute the command.
  337. //      1 - Show the option box dialog.
  338. //      2 - Return the command.
  339. //
  340. global proc string performMakeBrushSpring(int $action)
  341. {
  342.     string $cmd = "";
  343.  
  344.     switch ($action) {
  345.  
  346.         //    Execute the command.
  347.         //
  348.         case 0:
  349.             $cmd = `assembleCmd`;
  350.             eval($cmd);
  351.             break;
  352.  
  353.         //    Show the option box.
  354.         //
  355.         case 1:
  356.             makeBrushSpringOptions;
  357.             break;
  358.  
  359.         //    Return the command string.
  360.         //
  361.         case 2:
  362.             //    Get the command.
  363.             //
  364.             $cmd = `assembleCmd`;
  365.             break;
  366.     }
  367.     return $cmd;
  368. }
  369.  
  370.